package com.lyl.security.module.security.service;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import com.lyl.security.module.security.model.pojo.User;
import com.lyl.security.module.security.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Mr.Luo
 * @date 2022-09-05 10:28
 * @desc
 */
@Slf4j
@Service
public class UserServiceImpl implements UserService {
    List<User> userList = ListUtil.toList(
            User.builder().username("张三").password("{noop}123").build(),
            User.builder().username("李四").password("{noop}123").build(),
            User.builder().username("王五").password("{noop}123").build()
    );

    @Override
    public User findByUsername(String username) {
        return userList.stream()
                .filter(user -> ObjectUtil.equals(username, user.getUsername()))
                .findFirst().orElse(null);
    }
}
